import torch
import numpy as np
import torch.backends.cudnn as cudnn
import random


def setup_seed(seed):
    """
    固定随机种子
    :param seed:
    :return:
    """
    torch.manual_seed(seed)
    torch.cuda.manual_seed_all(seed)
    torch.cuda.manual_seed(seed)
    np.random.seed(seed)
    random.seed(seed)
    cudnn.deterministic = True